package com.bdqn.tour.dao.impl;

import com.bdqn.tour.dao.BaseDao;
import com.bdqn.tour.dao.HqfDeleteDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class HqfDeleteDaoImpl extends BaseDao implements HqfDeleteDao {

    @Override
    //根据景点id删除数据
    public int deleteScenic(int id) {
       int count = 0 ;
       //获取连接对象Connection
        Connection conn = this.getConnection();
        //初始化PreparedStatement
        PreparedStatement psmt = null;
        //初始化ResultSet
        ResultSet rs = null;
        //编写sql语句，根据id删除数据
     String sql = "delete from scenictable where scenic_id = ?";
        try {
            //创建预编译对象，?占位符
            psmt = conn.prepareStatement(sql);
            psmt.setInt(1,id);
            //执行sql语句
            count = psmt.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            this.closeAll(conn,psmt,rs);
        }
        return count;
    }
}
